<!-- el-select -->
<template>
  <el-select class="c-select" v-model="selectValue" :placeholder="placeholder" :size="size" :disabled="disabled"
    :clearable="clearable" :filterable="filterable" :remote="remote" :remote-method="remoteMethod" :loading="loading"
    :multiple="multiple" @change="handleChange">
    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" :disabled="item.disabled">
    </el-option>
  </el-select>
</template>

<script>
export default {
  name: '',
  data () {
    return {
      selectValue: '',
      loading: false
    }
  },
  props: {
    value: {
      type: String,
      default: ''
    },
    placeholder: {
      type: String,
      default: '请选择'
    },
    clearable: {
      type: Boolean,
      default: true
    },
    multiple: {
      type: Boolean,
      default: false
    },
    filterable: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    remote: {
      type: Boolean,
      default: false
    },
    options: {
      type: Array,
      default: () => []
    },
    remoteMethod: {
      type: Function,
      default: () => { }
    },
    size: {
      type: String,
      default: ''
    },
    styles: {
      type: Object,
      default: () => { }
    }
  },
  watch: {
    'value': function (val) {
      this.selectValue = this.value
    }
  },
  mounted () {
    this.selectValue = this.value
  },
  methods: {
    handleChange (value) {
      this.$emit('input', value)
      this.$emit('change', value)
    }
  }
}

</script>
